﻿// ActionScript file
package org.nickro.geom{
	import flash.geom.Point;
	
	public class PointUtil
	{
		/**
		 * 根据给定点、圆心点和半径算出两点连线与圆的交点坐标
		 * @param p    	  给点�?可以是任意给定点)
		 * @param radisP  圆心点坐�?
		 * @param radius  圆半�?
		 * 
		 */
		public static function getPointOnCircleEdge(p:Point,centerP:Point,radius:Number):Point
		{
			var angle:Number = Math.atan2((p.y - centerP.y),(p.x - centerP.x));
			if(angle < 0)
			{
				angle += 2*Math.PI;
			}
			var px:Number = Math.cos(angle) * radius + centerP.x;
			var py:Number = Math.sin(angle) * radius + centerP.y;
			return new Point(px,py);
		}
	}
}